import { ref, reactive } from "vue";
// 网络请求的
import axios from "axios";

export default function () {
  // 数据
  let dogList = reactive([
    "https://images.dog.ceo/breeds/pembroke/n02113023_6567.jpg",
  ]);

  // function dogAgain() {
  //   let result = axios
  //     .get("https://dog.ceo/api/breed/pembroke/images/random")
  //     .then(
  //       (response) => {
  //         console.log(response);
  //       },
  //       (error) => {}
  //     );
  // }

  // 方法
  async function dogAgain() {
    try {
      let result = await axios.get(
        "https://dog.ceo/api/breed/pembroke/images/random"
      );
      // console.log(result.data);
      dogList.push(result.data.message);
    } catch (error) {
      alert(error);
    }
  }

  return { dogList, dogAgain };
}
